const UserModel = require('../models/userModel')
const BookModel = require('../models/bookModel')
const LogModel = require('../models/logModel')
const Router = require('@koa/router')

const router = new Router({
    prefix: '/dashboard',
})

router.get('/base-info', async ctx => {
    const totalNumberOfBooks = await BookModel.countDocuments()
    const totalNumberOfUsers = await UserModel.countDocuments()
    const totalNumberOfLogs = await LogModel.countDocuments()

    ctx.body = {
        code: 1,
        data: {
            totalNumberOfBooks,
            totalNumberOfLogs,
            totalNumberOfUsers,
        },
    }
})

module.exports = router
